<?php
    #Include the connect.php file
    include($_SERVER["DOCUMENT_ROOT"].'/CTAN/models/Show.php');
    $buoibieudien = new buoibieudien();

    if (isset($_REQUEST['action'])){
        $action = ($_REQUEST['action']);
        if ($action=="insert"){
            //INSERT COMMAND
            $buoibieudien->setTenBuoiDien($_REQUEST['ten_buoi_dien']);
            $buoibieudien->setDiaDiem($_REQUEST['dia_diem']);
            $buoibieudien->setChiTietThem($_REQUEST['chi_tiet_them']);
            $buoibieudien->setThoiGianBD($_REQUEST['thoi_gian_bat_dau']);
            $buoibieudien->setThoiGianDien($_REQUEST['thoi_gian_dien']);
            $buoibieudien->setNgayDien($_REQUEST['ngay_dien']);
            $buoibieudien->setVeDaban(0);
            echo $buoibieudien->insertToDB();
        }
        elseif ($action=="edit") {
            // UPDATE COMMAND
            $buoibieudien->setMaBuoiDien($_REQUEST['ma_buoi_dien']);
            $buoibieudien->setTenBuoiDien($_REQUEST['ten_buoi_dien']);
            $buoibieudien->setDiaDiem($_REQUEST['dia_diem']);
            $buoibieudien->setChiTietThem($_REQUEST['chi_tiet_them']);
            $buoibieudien->setThoiGianBD($_REQUEST['thoi_gian_bat_dau']);
            $buoibieudien->setThoiGianDien($_REQUEST['thoi_gian_dien']);
            $buoibieudien->setNgayDien($_REQUEST['ngay_dien']);
            echo $buoibieudien->updateToDB();
        }
        elseif ($action=="delete") {
            $buoibieudien->setMaBuoiDien($_REQUEST['mabuoidien']);
            echo $buoibieudien->deleteFromDB();
        }
    }
    include_once($_SERVER["DOCUMENT_ROOT"]."/CTAN/views/Show_DanhSach.php");
    include_once($_SERVER["DOCUMENT_ROOT"]."/CTAN/views/Show_AdminTools.php");
    include_once($_SERVER["DOCUMENT_ROOT"]."/CTAN/views/Show_CapNhatTietMuc.php");
    include_once($_SERVER["DOCUMENT_ROOT"]."/CTAN/views/Show_ThongTin.php");
?>